<html>
<head>
	<title>Excersise 5</title>
	<link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
	<div id="js-console"></div>
	<script src="scripts/js-console.js"></script>
	<script>
		var persons = [
		{firstname: "Brian", lastname: "May", age: 22},
		{firstname: "Farrokh", lastname: "Bulsara", age: 45},
		{firstname: "Mike", lastname: "Patton", age: 15},
		]
jsConsole.writeLine("list of persons:");
for(i=0;i<3;i++)
{
jsConsole.writeLine("Name: " + persons[i].firstname + " "+persons[i].lastname + " - Age: " + persons[i].age);
}
		youngestPerson(persons);

		function youngestPerson(arr) 
		{
		    var counter = 0;
		    var youngestAge = 100;

		    for (var i in arr) 
			{
		        if (arr[i].age < youngestAge) 
				{
		            youngestAge = arr[i].age;
		            counter = i;
		        }
		    }

		    jsConsole.write("The youngest person is: "+arr[counter].firstname + " " + arr[counter].lastname + " - age of " + arr[counter].age + "\n");
	    }
	</script>
</body>
</html>
